import static org.junit.Assert.assertEquals;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

//import com.test.general.GenerateData;

public class RandomDataGen {
	
	//WebDriver driver;
	GenerateData genData;
	
	@Before
	public void before(){
		//driver=new FirefoxDriver();
		genData=new GenerateData();
	}
	
	@Test
	public void testRamdomData() {
		
		String a = genData.generateRandomAlphaNumeric(30);
		String b = genData.generateRandomString(20);
		String c = genData.generateEmail(30);
		//String d = generateStringWithAllobedSplChars(30, "abc123_-.");
		String e = genData.generateRandomNumber(10);
		String f = genData.generateRandomNumber(9);
		System.out.println("Value of a is: " + a);
		System.out.println("Value of b is: " + b);
		System.out.println("Value of c is: " + c);
	//	System.out.println("Value of d is: " + d);
		System.out.println("Value of e is: " + e);
		System.out.println("Value of f is: " + f);
	}
	
	@After
	public void after(){
		//driver.quit();
	}

	public class GenerateData {

		public String generateRandomString(int length){
			return RandomStringUtils.randomAlphabetic(length);
		}
		
		public String generateRandomNumber(int length){
			return RandomStringUtils.randomNumeric(length);
		}
		
		public String generateRandomAlphaNumeric(int length){
			return RandomStringUtils.randomAlphanumeric(length);
		}
		
		public String generateStringWithAllobedSplChars(int length,String allowdSplChrs){
			String allowedChars="abcdefghijklmnopqrstuvwxyz" +   //alphabets
					"1234567890" +   //numbers
					allowdSplChrs;
			return RandomStringUtils.random(length, allowedChars);
		}
		
		public String generateEmail(int length) {
			String allowedChars="abcdefghijklmnopqrstuvwxyz" +   //alphabets
					"1234567890" +   //numbers
					"_-.";   //special characters
			String email="";
			String temp=RandomStringUtils.random(length,allowedChars);
			email=temp.substring(0,temp.length()-9)+"@test.org";
			return email;
		}
		
		public String generateUrl(int length) {
			String allowedChars="abcdefghijklmnopqrstuvwxyz" +   //alphabets
					"1234567890" +   //numbers
					"_-.";   //special characters
			String url="";
			String temp=RandomStringUtils.random(length,allowedChars);
			url=temp.substring(0,3)+"."+temp.substring(4,temp.length()-4)+"."+temp.substring(temp.length()-3);
			return url;
		}
	}
		
}